package com.tuanzi.loan.business.service.galaxycard.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tuanzi.loan.business.entity.galaxycard.GalaxyCardPromoteUserChannel;
import com.tuanzi.loan.business.repository.galaxycard.GalaxyCardPromoteUserRelateChannelRepository;
import com.tuanzi.loan.business.repository.galaxycard.custom.GalaxyCardPromoteUserRelateChannelCustomRepository;
import com.tuanzi.loan.business.service.galaxycard.GalaxyCardPromoteUserRelateChannelService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.repository.JPAAuditRepository;
import com.tuanzi.loan.core.service.BaseAuditServiceImpl;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.galaxycard.GalaxyCardPromoteUserRelateChannelRequest;
import com.tuanzi.loan.vo.response.galaxycard.GalaxyCardPromoteUserRelateChannelResponse;

@Debug
@Service
@Transactional
@Retryable(value = { RetryException.class })
public class GalaxyCardPromoteUserRelateChannelServiceImpl extends BaseAuditServiceImpl<GalaxyCardPromoteUserChannel, Long> implements GalaxyCardPromoteUserRelateChannelService{
	
	@Autowired
	private GalaxyCardPromoteUserRelateChannelCustomRepository galaxyCardPromoteUserRelateChannelCustomRepository;
	
	@Autowired
	private GalaxyCardPromoteUserRelateChannelRepository galaxyCardPromoteUserRelateChannelRepository;

	@Override
	public Page<GalaxyCardPromoteUserRelateChannelResponse> list(
			PageSearcher<GalaxyCardPromoteUserRelateChannelRequest> pageSearcher) {
		return galaxyCardPromoteUserRelateChannelCustomRepository.list(pageSearcher.getSearchCondition(), pageSearcher.getPageable());
	}
	
	@Override
	public List<Integer> findChannelCodeListByUserId(String userId) {
		return galaxyCardPromoteUserRelateChannelCustomRepository.findChannelCodeListByUserId(userId);
	}

	@Override
	public GalaxyCardPromoteUserChannel findByUserIdAndChannelCode(
			String userId, Integer channelCode) {
		return galaxyCardPromoteUserRelateChannelRepository.findByUserIdAndChannelCode(userId, channelCode);
	}

	@Override
	protected JPAAuditRepository<GalaxyCardPromoteUserChannel, Long> getRepository() {
		return galaxyCardPromoteUserRelateChannelRepository;
	}

	


}
